#pragma once
#include "Types.h"
#include "TypeInfo.h"
#include "ReferenceCounter.h"
#include "DynamicCast.h"
#include <Rz/Utils/Cryptography/CryptographyBase.h>

#include <map>

namespace Rz {

class IObject :
	virtual public ReferenceCounter
{
	public:
		// forces calling destructors of derived classes
		virtual ~IObject();

 		virtual const ::Rz::TypeInfo* GetTypeInfo() const = 0;
		static const TypeInfo* GetTypeInfoStatic();

		//////////////////////////////////////////////////////////////////////////

		const void* To(Utils::Cryptography::Hash hash) const;
		void* To(Utils::Cryptography::Hash hash);

		RZ_AS_METHOD(IObject);

	protected:
		void RegisterSubclass(const void* ptr, Utils::Cryptography::Hash hash) const;
		virtual void RegisterAllSubclasses() const;

	private:
		void BuildInheritanceCache() const;

		mutable std::map<Utils::Cryptography::Hash, void*> _bases;
};

}
